package com.example.administrator.materialdesign;

import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;



/**
 * Created by Administrator on 2017/4/29.
 */

public class oneFragment extends Fragment implements View.OnClickListener{

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.one_fragment,container,false);//布局动态加载
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {                    //重载该方法，写按钮事件
        super.onActivityCreated(savedInstanceState);
        Button one_fragment_Button1=(Button)getActivity().findViewById(R.id.one_fragment_Button1);
        one_fragment_Button1.setOnClickListener(this);
    }

    /*点击事件处理*/
    public void onClick(View view){

        switch (view.getId()){
            case R.id.one_fragment_Button1:
                Toast.makeText(getActivity(), "这是一个按钮事件", Toast.LENGTH_SHORT).show();
        }
    }
}
